<template>
  <div class="app-container">
    <!-- 分组列表 -->
    <!-- 表格 -->
    <el-table
      :data="list"
      border
      fit
      highlight-current-row>

      <el-table-column
        label="序号"
        width="70"
        align="center">
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="groupName" label="组名"/>

      <el-table-column prop="description" label="组描述"/>

      <el-table-column prop="leader" label="组长"/>

      <el-table-column prop="leaderTwo" label="副组长"/>

      <el-table-column prop="volunteers" label="志愿者列表"/>

      <el-table-column prop="members" label="组成员列表"/>

      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="removeDataById(scope.row.id)">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
  </div>

</template>
<script>
import group from '@/api/management/group'

export default {
  data() {
    return {
      list: [],
      page: 1,
      limit: 10,
      total: 0,
      groupQuery: {},
      activityId: ''
    }
  },
  created() {
    if (this.$route.params && this.$route.params.id) {
      this.activityId = this.$route.params.id
      this.getList()
    }
  },
  methods: {
    getList() {
      group.getGroupInfoView(this.activityId).then(response => {
        this.list = response.data.list
      })
    },
    resetData() {
      //清空查询条件
      this.teacherQuery = {}
      //查询所有数据
      this.getList()
    },
    removeDataById(id) {
      this.$confirm('此操作将永久删除该分组及分组下的所有成员, 请谨慎操作！！！', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        //调用删除方法
        group.deleteGroup(id)
          .then(response => {
            //提示删除成功
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            //刷新列表
            this.getList()
          })
      })
    }
  }
}
</script>
